//
//  WorkerCell.m
//  HubeiHotel
//
//  Created by LiBenCan on 17/11/20.
//  Copyright © 2017年 张露杰. All rights reserved.
//

#import "WorkerCell.h"
#import "chooseBtnView.h"
@implementation WorkerCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    //    继承父类
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        self.selectionStyle = 0;
    }
    return self;
}

-(void)loadCellWithData:(NSDictionary *)data
{
    //    重新布局
    for (UIView *view in self.contentView.subviews) {
        [view removeFromSuperview];
    }
    
    UILabel *nameLabel = [TomamaUI createLabel:CGRectMake(25*screenW_6, 19*screenW_6, [TomamaUI getStringWeithtWith:data[@"name"] andHeigth:17*screenW_6 andFont:[UIFont systemFontOfSize:17*screenW_6]], 17*screenW_6) textAligment:0 font:[UIFont systemFontOfSize:17*screenW_6] textColor:TextBlack text:data[@"name"]];
    [self.contentView addSubview:nameLabel];
    
    UILabel *priceLabel = [TomamaUI createLabel:CGRectMake(CGRectGetMaxX(nameLabel.frame), 19*screenW_6, SCREENW - CGRectGetMaxX(nameLabel.frame) - 17*screenW_6, 17*screenW_6) textAligment:2 font:[UIFont systemFontOfSize:17*screenW_6] textColor:[UIColor colorWithHexString:@"#ff6900"] text:data[@"salary"]];
    [self.contentView addSubview:priceLabel];
    
    UIView *lastView;
    NSArray *imageArr = @[@"Find_dingwei_icon",@"Find_nianxian_icon",@"Find_benke_icon",@"Find_time_icon"];
    NSArray *titleArr = @[data[@"areaName"],data[@"workingLife"],data[@"education"],data[@"jobType"]];
    for (int i = 0; i < imageArr.count; i++) {
        UIImageView *icon;
        UILabel *label;
        if (i == 0) {
            icon = [TomamaUI createImageView:CGRectMake(25*screenW_6, CGRectGetMaxY(nameLabel.frame) + 18*screenW_6, 14*screenW_6, 14*screenW_6) backGroundImageV:imageArr[i]];
            [self.contentView addSubview:icon];
            
            label = [TomamaUI createLabel:CGRectMake(CGRectGetMaxX(icon.frame) + 4*screenW_6, 0, [TomamaUI getStringWeithtWith:titleArr[i] andHeigth:14*screenW_6 andFont:[UIFont systemFontOfSize:14*screenW_6]], 14*screenW_6) textAligment:0 font:[UIFont systemFontOfSize:14*screenW_6] textColor:[UIColor colorWithHexString:@"#666666"] text:titleArr[i]];
            [self.contentView addSubview:label];
            label.center = CGPointMake(label.center.x, icon.center.y);
        }else{
            icon = [TomamaUI createImageView:CGRectMake(CGRectGetMaxX(lastView.frame) + 21*screenW_6, CGRectGetMaxY(nameLabel.frame) + 18*screenW_6, 14*screenW_6, 14*screenW_6) backGroundImageV:imageArr[i]];
            [self.contentView addSubview:icon];
            
            label = [TomamaUI createLabel:CGRectMake(CGRectGetMaxX(icon.frame) + 4*screenW_6, 0, [TomamaUI getStringWeithtWith:titleArr[i] andHeigth:14*screenW_6 andFont:[UIFont systemFontOfSize:14*screenW_6]], 14*screenW_6) textAligment:0 font:[UIFont systemFontOfSize:14*screenW_6] textColor:[UIColor colorWithHexString:@"#666666"] text:titleArr[i]];
            [self.contentView addSubview:label];
            label.center = CGPointMake(label.center.x, icon.center.y);
        }
        lastView = label;
    }
    
    UILabel *fringeBenefitLabel = [TomamaUI createLabel:CGRectMake(25*screenW_6, CGRectGetMaxY(lastView.frame) + 13*screenW_6, SCREENW - 50*screenW_6, 14*screenW_6) textAligment:0 font:[UIFont systemFontOfSize:14*screenW_6] textColor:[UIColor colorWithHexString:@"#666666"] text:[NSString stringWithFormat:@"职业诱惑：%@",data[@"fringeBenefits"]]];
    [self.contentView addSubview:fringeBenefitLabel];
    
    UIView *lineView = [[UIView alloc]initWithFrame:CGRectMake(25*screenW_6, CGRectGetMaxY(fringeBenefitLabel.frame) + 23*screenW_6, SCREENW - 25*screenW_6, 1)];
    lineView.backgroundColor = backColor;
    [self.contentView addSubview:lineView];
    
    UIImageView *comIcon = [TomamaUI createImageView:CGRectMake(25*screenW_6, CGRectGetMaxY(lineView.frame) + 15*screenW_6, 37.5*screenW_6, 37.5*screenW_6) backGroundImageV:@""];
    comIcon.layer.masksToBounds = YES;
    comIcon.layer.cornerRadius = comIcon.frame.size.height/2;
    [self.contentView addSubview:comIcon];
    [comIcon sd_setImageWithURL:[NSURL URLWithString:data[@"companyLogo"]] placeholderImage:[UIImage imageNamed:@"companyLogo"]];
    
    UILabel *comNameLabel = [TomamaUI createLabel:CGRectMake(CGRectGetMaxX(comIcon.frame) + 9*screenW_6, CGRectGetMaxY(lineView.frame) + 20*screenW_6, [TomamaUI getStringWeithtWith:data[@"companyName"] andHeigth:14*screenW_6 andFont:[UIFont systemFontOfSize:14*screenW_6]], 14*screenW_6) textAligment:0 font:[UIFont systemFontOfSize:14*screenW_6] textColor:TextBlack text:data[@"companyName"]];
    [self.contentView addSubview:comNameLabel];
    
    NSArray *details = @[data[@"financingPhase"],data[@"companyNumber"],data[@"industryField"]];
    for (int i = 0; i < details.count; i++) {
        UILabel *label;
        if ( i == 0) {
            label = [TomamaUI createLabel:CGRectMake(CGRectGetMaxX(comIcon.frame) + 9*screenW_6, CGRectGetMaxY(comNameLabel.frame) + 7*screenW_6, [TomamaUI getStringWeithtWith:details[i] andHeigth:11*screenW_6 andFont:[UIFont systemFontOfSize:11*screenW_6]], 11*screenW_6) textAligment:0 font:[UIFont systemFontOfSize:11*screenW_6] textColor:[UIColor colorWithHexString:@"#999999"] text:details[i]];
            [self.contentView addSubview:label];
        }else{
            label = [TomamaUI createLabel:CGRectMake(CGRectGetMaxX(lastView.frame) + 20*screenW_6, CGRectGetMaxY(comNameLabel.frame) + 7*screenW_6, [TomamaUI getStringWeithtWith:details[i] andHeigth:11*screenW_6 andFont:[UIFont systemFontOfSize:11*screenW_6]], 11*screenW_6) textAligment:0 font:[UIFont systemFontOfSize:11*screenW_6] textColor:[UIColor colorWithHexString:@"#999999"] text:details[i]];
            [self.contentView addSubview:label];
        }
        lastView = label;
        if (i < 2) {
            UIView *lineView = [[UIView alloc]initWithFrame:CGRectMake(CGRectGetMaxX(label.frame) + 9*screenW_6, 0, 1, 11*screenW_6)];
            lineView.backgroundColor = backColor;
            [self.contentView addSubview:lineView];
            lineView.center = CGPointMake(lineView.center.x, label.center.y);
        }
    }
    
    UIImageView *next = [TomamaUI createImageView:CGRectMake(SCREENW - 24*screenW_6, 0, 9*screenW_6, 15*screenW_6) backGroundImageV:@"right"];
    [self.contentView addSubview:next];
    next.center = CGPointMake(next.center.x, comIcon.center.y);
    
    UIButton *btn = [[UIButton alloc]initWithFrame:CGRectMake(0, CGRectGetMaxY(lineView.frame), SCREENW, 72.5*screenW_6)];
    [btn addTarget:self action:@selector(detail) forControlEvents:UIControlEventTouchUpInside];
    [self.contentView addSubview:btn];
}

-(void)detail
{
    if (_blcok) {
        _blcok();
    }
}

@end
